package com.glx.learn_spring.learn_spring_03_bean_instance;

import com.glx.learn_spring.learn_spring_03_bean_instance.dao.IUserDao;
import com.glx.learn_spring.learn_spring_03_bean_instance.factory.UserDaoFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author haoli
 * @create 2022/11/30 13:03
 */
public class AppForInstanceUser {
    public static void main(String[] args) {
        // 通过实例工厂创建对象
        //UserDaoFactory userDaoFactory = new UserDaoFactory();
        //IUserDao userDao = userDaoFactory.getInstance();
        //userDao.save();

        // 使用 Ioc 容器通过实例化工厂创建bean
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        IUserDao userDao2 = ctx.getBean("userDao", IUserDao.class);
        userDao2.save();
    }
}
